<template>
  <div class="login">
    <div class="box">
      <div class="row">
        <h2>修改管理员信息</h2>
      </div>
      <div class="row">
        <span>账户：</span>
        <el-input placeholder="请输入用户名" v-model="inputAccount" clearable disabled></el-input>
      </div>
      <div class="row">
        <span>昵称：</span>
        <el-input placeholder="请输入昵称" v-model="inputNick" clearable></el-input>
      </div>
       <div class="row">
        <span>邮箱：</span>
        <el-input placeholder="请输入昵称" v-model="inputEmail" clearable></el-input>
      </div>
      <div class="row">
        <span>密码：</span>
        <el-input
          placeholder="请输入密码"
          v-model="inputPassword"
          clearable
          show-password
          @keyup.native.enter="login"
        ></el-input>
      </div>
      <div class="row">
        <span></span>
        <el-button type="primary" @click="modifyInfo">修改</el-button>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "login",
  data() {
    return {
      inputAccount: "",
      inputNick:"",
      inputEmail:"",
      inputPassword: "",
      loginData: {},
      checked: true
    };
  },
  mounted() {
    this.managerDetailMe();
  },
  methods: {
    async modifyInfo() {
      if (!this.inputNick) {
        this.$message("昵称不能为空！");
        return;
      }

      let parames = {
        handshake: "",
        data: {
          nick:this.inputNick,
          email:this.inputEmail,
          password: this.inputPassword
        }
      };
      let res = await this.$axios.post(
        this.$api.managerModifyMe,
        JSON.stringify(parames)
      );
      if (res.code == 200) {
        this.$message({
          message: res.message,
          type: "success"
        });
        this.$router.push({ path: "/index" });
      } else {
         this.$message({
          message: res.message,
          type: "warning"
        });
      }
    },

    //管理员自己权限详情
    async managerDetailMe() {
      let parames = {
        handshake: "",
        data: {}
      };
      let res = await this.$axios.post(
        this.$api.managerDetailMe,
        JSON.stringify(parames)
      );
      if (res.code == 200) {
        this.permissionsDetail = res.data;
        this.inputAccount=this.permissionsDetail.username;
        this.inputNick=this.permissionsDetail.nick;
        this.inputEmail=this.permissionsDetail.email;
      } else {
        this.$message(res.message);
      }
    }
  }
};
</script>
<style scoped>
.login {
  width: 100%;
  height: 100vh;
  background: linear-gradient(45deg, #1278f6, #00b4aa 50%, #1278f6);
  display: flex;
  justify-content: center;
  align-items: center;
}
.box {
  width: 5rem;
  background: #fff;
  padding: 0.6rem 0.4rem;
}
.box .row {
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.16rem;
  margin-bottom: 0.3rem;
}
.box .row span {
  width: 0.5rem;
}
.el-input {
  width: 70%;
}
.el-button {
  width: 70%;
}
.row .rowCheck {
  width: 70%;
  display: flex;
  justify-content: flex-end;
}
</style>